<script src="./equal.js"></script>
<script>
  {
    const typeOfSet = 'function'
    console.assert(typeOfSet === typeof Set)
  }
  {
    let set = new Set()
    set.add(1)
    set.add(1)
    const actualSize =1
    console.assert(actualSize === set.size)
  }
  {
    let set = new Set()
    set.add(1)
    set.add(2)
    console.assert(set.size === 2)
  }
  {
    let set = new Set()
    set.add(NaN)
    set.add(NaN)
    console.assert(set.size === 1)
  }
  {
    let set = new Set()
    set.add(+0)
    set.add(0)
    set.add(-0)
  
    console.assert(equal([...set.values()], [+0]))
  }
  {
    let set = new Set()
    const fn = () => {}
    set.add(1)
    set.add(1)
    set.add(fn)
    set.add(fn)
    console.assert(set.size === 2)
  }
  {
    let set = new Set()
    set.add(1).add(2)
    console.assert(set.has(2) === true)
  }
  {
    let set = new Set()
    set.add(void 0)
    console.assert(set.has(void 0) === true)
  }
  {
    let set = new Set()
    set.add(+0)
    set.add(+0)
    console.assert(set.has(+0) === true)
  }

  {
    let set = new Set()
    set.add('one').add('two').add('three')
    const returns = set.delete('three')
    console.assert(returns === true)
    console.assert(set.size === 2)
  }

  {
    let set = new Set()
    set.add('one').add('two').add('three')
    set.add()
    // set.has(whatToDelete)
    const whatToDelete='k'
    const returns = set.delete('1')
    console.assert(returns === false)
    console.assert(set.delete('whatToDelete') === false)
    console.assert(set.delete() === true)
  }
  {
    let set = new Set()
    set.add('one').add('two').add('three')
    set.add(1)
    set.has('1')
    console.assert(set.delete('1') === false)
  }

  const api = ['size', 'add', 'clear', 'delete', 'entries', 'forEach', 'has', 'keys', 'values'];
  let set = new Set(api);
  {
    let set = new Set([...api]);
    console.assert(equal(Array.from(set), api));
  }

  {
    const theSize = set.size;
    console.assert(theSize === api.length);
  }
  {
     set.size = set.add(1)
    console.assert(set.size === api.length + 1);
  }
  {
    set = new Set(api)
    set.size=set.delete([...api][1])
    console.assert(set.size === api.length - 1);
  }
  {
    set.size=set.clear()
    console.assert(set.size === 0);
  }
  {
    set = new Set(api)
    const expectedEntries = api.map(entry => [entry, entry]);
    const actualEntries =set.entries();
    console.assert(equal([...actualEntries], expectedEntries));
  }

  {
    const propertyName = '';
  set.add(propertyName)
    console.assert(set.has(propertyName) === true);
  }

  {
    set=new Set(api)
    const allKeys = set.keys();
    console.assert(equal([...allKeys], api));
  }
</script>
